var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("GameConfig"), i = e("GameData"), a = e("Global"), r = e("WebManager"), s = function() {
    function e() {}
    return e.getInstance = function() {
        return this._manager || (this._manager = new e()), this._manager;
    }, e.prototype.check = function() {
        var e, n = a.G.checkSeason();
        -1 == n ? (cc.log("赛季未开启"), a.G.seasoncount = -1, e = a.G.formatDate(o.GC.seasonDateConfig).getTime(), 
        a.G.seasonNextTime = e - Date.now()) : (a.G.season = n, e = a.G.formatDate(o.GC.seasonDateConfig).getTime() + (o.GC.seasonContinueConfig + o.GC.seasonIntervalConfig) * n * a.G.ONE_DAY_TIME, 
        a.G.seasonNextTime = e - Date.now(), a.G.seasonTime = a.G.seasonNextTime - o.GC.seasonIntervalConfig * a.G.ONE_DAY_TIME, 
        0 < a.G.seasonTime ? (i.GD.seasonLastTime < e ? (this.account(n), cc.log("开启s" + n + "赛季")) : cc.log("赛季s" + n + "已开启"), 
        a.G.seasoncount = n % o.GC.seasonCountConfig, i.GD.seasonOpenTime < i.GD.seasonLastTime && !i.GD.isOpen ? i.GD.isNew ? (cc.log("新玩家没有赛季奖励"), 
        i.GD.isOpen = 1, i.GD.isReward = 1, i.GD.seasonOpenTime = i.GD.seasonLastTime, i.GD.seasonRewardTime = i.GD.seasonLastTime) : (cc.log("老玩家结算领取赛季奖励"), 
        a.G.queue.push({
            name: "season",
            type: 2
        })) : cc.log("赛季s" + n + "开启动画已播放")) : (cc.log("s" + n + "赛季已结束"), a.G.seasoncount = -2)), 
        GA.Info.underCheck || o.GC.isDebug || r.default.getInstance().saveMatchRank({
            score: i.GD.score,
            needHeadIcon: 0,
            success: function(e) {
                console.log("saveMatchRank", e);
            }
        });
    }, e.prototype.account = function(e) {
        cc.log("结算s" + (e - 1) + "赛季"), i.GD.lastLevel = i.GD.level, i.GD.curLevel = 0, 
        i.GD.lastScore = i.GD.score, i.GD.score = 1e3, i.GD.curScore = 0, i.GD.lastWinNum = i.GD.winNum, 
        i.GD.winTotal += i.GD.winNum, i.GD.winNum = 0, i.GD.isOpen = 0, i.GD.isReward = 0, 
        i.GD.seasonLastTime = a.G.formatDate(o.GC.seasonDateConfig).getTime() + (o.GC.seasonContinueConfig + o.GC.seasonIntervalConfig) * e * a.G.ONE_DAY_TIME;
        var n = a.G.getRank(i.GD.level);
        if (0 == n.r) i.GD.seasonOpenTime = i.GD.seasonLastTime, i.GD.seasonRewardTime = i.GD.seasonLastTime; else for (var s = 0; s < o.GC.seasonRankConfig.length; s++) if (n.r == o.GC.seasonRankConfig[s].r) {
            n.r = o.GC.seasonRankConfig[s].n, n.s = 0, i.GD.level = a.G.getLevel(n);
            break;
        }
    }, e._manager = null, e;
}();

n.default = s;